package com.example.demo.common;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2023-03-19
 * Time: 18:33
 */

//自定义统一数据返回封装
public class AjaxResult {

    public static HashMap<String,Object> success(Object body) {
        HashMap<String,Object> result = new HashMap<>();
        result.put("code",200);
        result.put("meg","");
        result.put("data",body);
        return result;
    }

    public static HashMap<String,Object> success(String message,Object body) {
        HashMap<String,Object> result = new HashMap<>();
        result.put("code",200);
        result.put("meg",message);
        result.put("data",body);
        return result;
    }

    public static HashMap<String,Object> fail(int code,String message) {
        HashMap<String,Object> result = new HashMap<>();
        result.put("code",code);
        result.put("meg",message);
        result.put("data","");
        return result;
    }
}
